﻿using B.S.Basic.ErrorCode;
using B.S.Basic.Read.API.Application;
using B.S.Basic.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Basic.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<ManagementController> logger;
        public ManagementController(IMediator mediator, ILogger<ManagementController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        [HttpGet]
        public async Task<APIResult<APIPaging<MyDTO>>> Show([FromQuery]ShowCommand command)
        {
            try
            {
                logger.LogInformation("调用显示方法");
                return await mediator.Send(command);
            }
            catch (Exception ex)
            {
                logger.LogError("添加显示出错" + ex.Message);
                throw;
            }
            
        }
    }
}
